package com.ftg.learn.util;

/**
 * @author kangjx
 * @date 2024/2/28
 */
public class ToWeb {

    private int code;

    private String msg;

    private Object data;

    public static ToWeb success(Object data){
        ToWeb toWeb = new ToWeb();
        toWeb.setCode(200);
        toWeb.setMsg("恭喜您，成功了");
        toWeb.setData(data);
        return toWeb;
    }

    public static ToWeb failure(Object data){
        ToWeb toWeb = new ToWeb();
        toWeb.setCode(500);
        toWeb.setMsg("对不起，失败了");
        toWeb.setData(data);
        return toWeb;
    }

    public static ToWeb failure(String msg,Object data){
        ToWeb toWeb = new ToWeb();
        toWeb.setCode(500);
        toWeb.setMsg(msg);
        toWeb.setData(data);
        return toWeb;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
